/****************************************************************************************************
		
Replication file 3 out of 3 for:
"The Intractability of Islamist Insurgencies: Islamist Rebels and the Recurrence of Civil War"
Desirée Nilsson & Isak Svensson
International Studies Quarterly
Last updated: 20 April 2021

***************************************************************************************************/

**Termination: two-year gap instead of 1-year gap**

clear all
use "Termination-data-2years-ISQ.dta"
sort dyadid year


************************************************
* STSET FOR SURVIVAL ANALYSIS
************************************************

stset end_of_segment, id(dyadid) origin(time first_year_of_con) enter(time start_of_segment) failure(term==1) exit(time .)


************************************************
* CONTROL VARIABELS
************************************************

global X1 territory strongstart oilstart youthstartap muslimajstart


************************************************
* TABLE A6
************************************************

*Model 1*     
stcox islamist $X1, cluster(dyadid) strata(order) nolog
outreg using appendix-A6a.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

capture drop sch* sca*
stcox islamist $X1, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

************************************************************************************************************************************************************************************

************************************************************************************************************************************************************************************

**Recurrence: two-year gap instead of 1-year gap**

clear all
use "Recurrence-data-2years-ISQ.dta"
sort dyadid year


************************************************
* STSET FOR SURVIVAL ANALYSIS - RECURRENCE
************************************************

stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)


************************************************
* CONTROL VARIABELS
************************************************

global X1 territory strongstart oilstart youthstartap muslimajstart


************************************************
* TABLE A6
************************************************

*Model 2*
capture drop sch* sca*
stcox islamist $X1, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

gen strongstartt=strongstart*ln(_t)
gen youthstartapt=youthstartap*ln(_t)

capture drop sch* sca*
stcox islamist $X1 youthstartapt strongstartt, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

stcox islamist $X1 strongstartt youthstartapt, cluster(dyadid) strata(order)  nolog
outreg using appendix-A6b.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace


************************************************
* STSET FOR SURVIVAL ANALYSIS - RECURRENCE-NEW
************************************************

stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

************************************************
* TABLE A6
************************************************

*Model3*
capture drop sch* sca*
stcox islamist $X1, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

stcox islamist $X1, cluster(dyadid) strata(order)  nolog
outreg using appendix-A6b.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge


************************************************************************************************************************************************************************************

************************************************************************************************************************************************************************************
